package io.github.eric.urpc.example.example;

import io.github.eric.urpc.client.Client;
import io.github.eric.urpc.client.ClientConfig;
import io.github.eric.urpc.example.SimpleClient;
import io.github.eric.urpc.example.SimpleServer;
import io.github.eric.urpc.example.msg.EchoMsg;

import java.util.ArrayList;
import java.util.List;

public class TooManyClientsExample {
    public static void main(String[] args) {
        SimpleServer simpleServer = new SimpleServer();
        simpleServer.start();

        List<Client> clients = new ArrayList<>();
        for (int i = 0; i < 1000; i++) {
            // init config
            ClientConfig clientConfig = new ClientConfig.Builder()
//                .nettyLoggingLevel(LogLevel.INFO)
                    .applicationName("simpleClient"+i)
                    .serverHost("127.0.0.1")
                    .serverPort(52379)
                    .build();

            // init client and connect to server
            Client client = new Client(clientConfig);
            clients.add(client);
            client.sendAsync(new EchoMsg());
        }
    }
}
